package com.hxzy.controller.storetype;

import com.alibaba.fastjson.JSONObject;
import com.hxzy.common.BaseServlet;
import com.hxzy.common.ResultAjax;
import com.hxzy.entity.StoreType;
import com.hxzy.service.StoreTypeServie;
import com.hxzy.service.impl.StoreTypeServieImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description:
 * @Author: ykj
 * @Date: 2022/3/8 23:12
 */
@WebServlet(urlPatterns = "/delete/storetype")
public class DeleteStoretype extends BaseServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        StoreType storeType = super.CollectiongParameterToJSON(req, StoreType.class);
        try {
            StoreTypeServie servie=new StoreTypeServieImpl();
            int delete = servie.delete(storeType.getRstId());
            ResultAjax resultAjax;
            if (delete>0){
                resultAjax=ResultAjax.success("删除成功");
            }else {
                resultAjax=ResultAjax.error("删除失败");
            }
            super.render(resp, JSONObject.toJSONString(resultAjax));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
